<?php
namespace ImiDemo\HttpDemo\MainServer\Model;

use Imi\Model\Model;
use Imi\Model\Annotation\Table;
use Imi\Model\Annotation\Column;
use Imi\Model\Annotation\Entity;
use Imi\Model\Annotation\Relation\AutoSelect;
use Imi\Model\Annotation\Relation\JoinToMiddle;
use Imi\Model\Annotation\Relation\JoinFromMiddle;
use Imi\Model\Annotation\Relation\PolymorphicToMany;

/**
 * Tags
 * @Entity
 * @Table(name="tb_tags", id={"id"})
 * @property int $id
 * @property string $name
 */
class Tags extends Model
{
	/**
	 * id
	 * @Column(name="id", type="int", length=10, accuracy=0, nullable=false, default="", isPrimaryKey=true, primaryKeyIndex=0, isAutoIncrement=true)
	 * @var int
	 */
	protected $id;

	/**
	 * 获取 id
	 *
	 * @return int
	 */ 
	public function getId()
	{
		return $this->id;
	}

	/**
	 * 赋值 id
	 * @param int $id id
	 * @return static
	 */ 
	public function setId($id)
	{
		$this->id = $id;
		return $this;
	}

	/**
	 * name
	 * @Column(name="name", type="varchar", length=32, accuracy=0, nullable=false, default="", isPrimaryKey=false, primaryKeyIndex=-1, isAutoIncrement=false)
	 * @var string
	 */
	protected $name;

	/**
	 * 获取 name
	 *
	 * @return string
	 */ 
	public function getName()
	{
		return $this->name;
	}

	/**
	 * 赋值 name
	 * @param string $name name
	 * @return static
	 */ 
	public function setName($name)
	{
		$this->name = $name;
		return $this;
	}

	/**
     * 拥有本标签的文章列表
     * 
     * @PolymorphicToMany(model=ImiDemo\HttpDemo\MainServer\Model\Article::class, modelField="id", type="taggable_type", typeValue=1, field="taggable_id", middle="Taggables")
     * @JoinToMiddle(field="id", middleField="taggable_id")
     * @JoinFromMiddle(middleField="tag_id", field="id")
	 * 
     * @AutoSelect(false)
     *
     * @var \Imi\Util\ArrayList
     */
    protected $articles;

    /**
     * Get 拥有本标签的模型列表
     *
     * @return  \Imi\Util\ArrayList
     */ 
    public function getArticles()
    {
        return $this->articles;
    }

    /**
     * Set 拥有本标签的模型列表
     *
     * @param  \Imi\Util\ArrayList  $articles  拥有本标签的模型列表
     *
     * @return  self
     */ 
    public function setArticles(\Imi\Util\ArrayList $articles)
    {
        $this->articles = $articles;

        return $this;
	}
	
	/**
     * 拥有本标签的书籍列表
     * 
     * @PolymorphicToMany(model=ImiDemo\HttpDemo\MainServer\Model\Book::class, modelField="id", type="taggable_type", typeValue=2, field="taggable_id", middle="Taggables")
     * @JoinToMiddle(field="id", middleField="taggable_id")
     * @JoinFromMiddle(middleField="tag_id", field="id")
	 * 
     * @AutoSelect(false)
     *
     * @var \Imi\Util\ArrayList
     */
    protected $books;

    /**
     * Get 拥有本标签的书籍列表
     *
     * @return  \Imi\Util\ArrayList
     */ 
    public function getBooks()
    {
        return $this->books;
    }

    /**
     * Set 拥有本标签的书籍列表
     *
     * @param  \Imi\Util\ArrayList  $books  拥有本标签的书籍列表
     *
     * @return  self
     */ 
    public function setBooks(\Imi\Util\ArrayList $books)
    {
        $this->books = $books;

        return $this;
	}
	
}